using System;

namespace MetaView.Core;

public class EasyMemoryMarshal
{
    public static unsafe ReadOnlySpan<T> CreateReadOnlySpanRef<T>(ref T reference, int length)
    {
        // 使用不安全代码创建
        fixed (T* ptr = &reference)
        {
            return new ReadOnlySpan<T>(ptr, length);
        }
    }

    public static unsafe ReadOnlySpan<T> CreateReadOnlySpanRef<T>(ref T reference)
    {
        // 使用不安全代码创建
        fixed (T* ptr = &reference)
        {
            return new ReadOnlySpan<T>(ptr, 1);
        }
    }
}
